***********************************************************************************************
*** TABLE A7: Dynamic Effect of Hearings on IP Rate, above and below median IP rate
***********************************************************************************************

use "$DATALOC/AgencyLevel.dta", clear
keep if agen_above50 == 1
eststo app_a_a50_1: reghdfe iprate agen_hear_all last_agen_hear ,  a(agency FY, savefe)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Hearing effects by chamber
eststo app_a_a50_2: reghdfe iprate agen_hear_h agen_hear_s last_agen_hear_h last_agen_hear_s,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Unified vs divided government
eststo app_a_a50_3: reghdfe iprate agen_hear_all last_agen_hear agen_hearXuni last_agenXuni,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	
	
use "$DATALOC/AgencyLevel.dta", clear
keep if agen_above50 == 0
eststo app_a_b50_1: reghdfe iprate agen_hear_all last_agen_hear ,  a(agency FY, savefe)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Hearing effects by chamber
eststo app_a_b50_2: reghdfe iprate agen_hear_h agen_hear_s last_agen_hear_h last_agen_hear_s,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Unified vs divided government
eststo app_a_b50_3: reghdfe iprate agen_hear_all last_agen_hear agen_hearXuni last_agenXuni,  a(agency FY)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	 



use "$DATALOC/ProgramLevel.dta", clear
keep if program_above50 == 1
eststo app_p_a50_1: reghdfe iprate agen_hear_all last_agen_hear ,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Hearing effects by chamber
eststo app_p_a50_2: reghdfe iprate agen_hear_h agen_hear_s last_agen_hear_h last_agen_hear_s,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Unified vs divided government
eststo app_p_a50_3: reghdfe iprate agen_hear_all last_agen_hear agen_hearXuni last_agenXuni,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	
	
use "$DATALOC/ProgramLevel.dta", clear
keep if program_above50 == 0
eststo app_p_b50_1: reghdfe iprate agen_hear_all last_agen_hear ,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Hearing effects by chamber
eststo app_p_b50_2: reghdfe iprate agen_hear_h agen_hear_s last_agen_hear_h last_agen_hear_s,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Unified vs divided government
eststo app_p_b50_3: reghdfe iprate agen_hear_all last_agen_hear agen_hearXuni last_agenXuni,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	 	
	
	
*** OUTPUT TABLE
esttab app_a_b50_1 app_a_a50_1 app_p_b50_1 app_p_a50_1 using "$TABLELOC/TableA07.tex", ///
	prehead("\begin{table}[htbp]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \caption{Dynamic Effect of Hearings on Improper Payment Rate, Low and High Mean IP rates. Dependent variable is improper payment rate as a percent of all payments.} \resizebox{\textwidth}{!}{ \begin{tabular}{l*{5}{c}} \toprule") ///
	b(a2) fragment ///
	booktabs label se star(** 0.05 *** 0.01)s(fixedyear fixedagency N, label("Fiscal Year FE" "Agency/Program FE" "Observations")) ///
	order(last_agen_hear agen_hear_all ) keep(agen* last*) ///
	nomtitles ///
	mgroups("Agency-level" "Program-level", ///
				pattern(1 0 1 0) ///
				span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	prefoot("\hline") ///
	postfoot("\bottomrule \multicolumn{5}{l}{\footnotesize Standard errors in parentheses; clustered on agency-year for program-level analysis.} \\ \multicolumn{5}{l}{\footnotesize \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\ \end{tabular} } \\ \label{tab:het} \end{table}") replace

	
		
